<template>
  <div v-if="show" style="font-size: 12px">
    <div style="width: 80%; margin-left: 9%"></div>
    <div style="display: flex; justify-content: space-around; font-size: 12px">
      <div>
        <h3>售后商品</h3>
        <div style="margin-top: 10px">{{ dateList.item.goods_name }}</div>
        <div style="color: #6a6666; margin-top: 10px">
          {{ dateList.item.attr_name }}
        </div>
      </div>
      <div>
        <h3>售后信息</h3>
        <div style="margin-top: 10px">
          售后方式：
          <span style="color: red">{{ dateList.after_type_name }}</span>
        </div>
        <div style="margin-top: 10px">
          退款金额:
          <span style="color: red">￥{{ dateList.item.refund_amount }}</span>
        </div>
        <div style="margin-top: 10px">
          联系方式：{{ dateList.customer_tel }}
        </div>
        <div style="margin-top: 10px">
          退款原因：{{ dateList.refund_reason }}
        </div>
        <div style="margin-top: 10px">退款说明:{{ dateList.after_remark }}</div>
        <!-- <div style="margin-top: 10px">售后历史：1</div> -->
      </div>
      <div>
        <h3>购买信息</h3>
        <div style="margin-top: 10px">
          商品单价：
          <span style="color: red">￥{{ dateList.item.refund_amount }}</span>
          X1件
        </div>
        <div style="margin-top: 10px">
          实付金额：
          <span style="color: red">￥{{ dateList.item.refund_amount }}</span>
        </div>
        <!-- <div style="margin-top: 10px">发货件数：0件</div> -->
        <!-- <div style="margin-top: 10px">发货状态：未发货</div> -->
        <div style="margin-top: 10px;color:color: #1890ff;">
          订单编码：
          <span>{{ dateList.after_sn }}</span>
        </div>
      </div>
    </div>
    <div style="margin-left: 9%; width: 90%">
      <h3>协商记录</h3>
      <div
        v-for="(items, index) in dateList.record"
        :key="index"
        style="display: flex"
      >
        <div
          style="
            width: 50px;
            height: 50px;
            border-radius: 50px;
            background: #a69d9d;
            text-align: center;
            line-height: 50px;
            font-size: 16px;
          "
        >
          {{ items.operator_name }}
        </div>
        <div style="width: 100%; background: #f3f3f3; margin-left: 10px">
          <div
            style="
              height: 50px;
              line-height: 50px;
              margin-left: 10px;
              border-bottom: 1px solid rgb(194 194 194);
            "
          >
            {{ items.title }}
          </div>
          <div
            v-for="(itemse, key) in items.record"
            :key="key"
            style="margin-left: 10px"
          >
            <p>{{ itemse }}</p>
          </div>
        </div>
      </div>
    </div>
    <el-dialog
      :before-close="handleClose"
      title="处理"
      :visible.sync="dialogVisible"
      width="30%"
    >
      <el-form ref="form" label-width="80px" :model="form">
        <el-form-item label="是否同意">
          <el-select v-model="form.verify_status" disabled placeholder="请选择">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item v-if="form.verify_status == 'refuse'" label="拒绝原因">
          <el-input
            v-model="form.verify_remark"
            placeholder="请输入内容"
            style="width: 80%"
          />
        </el-form-item>
        <el-form-item v-if="dateList.must_info == 'Y'" label="收款信息">
          <el-input
            v-model="form.refund_info"
            placeholder="请输入内容"
            style="width: 80%"
          />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="submit">确 定</el-button>
      </span>
    </el-dialog>
    <div
      v-permissions="{ permission: ['check:AfterOrder'] }"
      style="margin-left: 45%"
    >
      <el-button
        :disabled="dshow"
        style="height: 30px; margin-top: 20px; margin-bottom: 10px"
        type="primary"
        @click="agree"
      >
        同意退款
      </el-button>
      <el-button
        :disabled="dshow"
        style="height: 30px; margin-top: 20px; margin-bottom: 10px"
        type="danger"
        @click="refuse"
      >
        拒绝退款
      </el-button>
      <el-button
        style="height: 30px; margin-top: 20px; margin-bottom: 10px"
        @click="goBack"
      >
        返回
      </el-button>
    </div>
  </div>
</template>

<script>
  //
  import { afterDetail, afterVerify } from '@/api/order'

  export default {
    props: {
      afterId: {
        type: Number,
        required: true,
      },
    },

    data() {
      return {
        dialogVisible: false,
        dateList: {},
        show: false,
        dshow: true,
        form: {},
        options: [
          {
            value: 'agree',
            label: '同意',
          },
          {
            value: 'refuse',
            label: '拒绝',
          },
        ],
      }
    },
    watch: {},

    created() {},
    mounted() {
      this.init()
    },
    methods: {
      init() {
        this.show = false
        const data = {
          after_id: this.afterId,
        }
        afterDetail(data).then((e) => {
          this.show = true
          this.dateList = e.data
          this.show = true
          if (e.data.verify_status == 'wait') {
            this.dshow = false
          }
        })
      },
      afterSaleClick() {
        this.form = {}
        this.dialogVisible = true
      },
      agree() {
        this.dialogVisible = true
        this.form.verify_status = 'agree'
      },
      refuse() {
        this.dialogVisible = true
        this.form.verify_status = 'refuse'
      },
      submit() {
        this.form.after_id = this.afterId
        afterVerify(this.form).then(() => {
          this.dialogVisible = false
          this.goBack()
        })
      },
      handleClose(done) {
        this.$confirm('确认关闭？')
          .then(() => {
            done()
          })
          .catch(() => {})
      },
      goBack() {
        this.$emit('showMain', 0)
      },
    },
  }
</script>

<style></style>
